import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:hook_up_rent/pages/home/index.dart';
import 'package:hook_up_rent/pages/login.dart';
import 'package:hook_up_rent/pages/not_found.dart';
import 'package:hook_up_rent/pages/register.dart';
import 'package:hook_up_rent/pages/room_detail/index.dart';

class Routes {
  static String home = "/";
  static String login = "/login";
  static String register = "/register";
  static String roomDetail = "/room/:roomId";

  static final Handler _homeHandler = Handler(
    handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      return const HomePage();
    },
  );

  static final Handler _roomDetailHandler = Handler(
    handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      return RoomDetailPage(roomId: parameters["roomId"]![0]);
    },
  );

  static final Handler _loginHandler = Handler(
    handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      return const LoginPage();
    },
  );

  static final Handler _registerHandler = Handler(
    handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      return const RegisterPage();
    },
  );

  static final Handler _notFoundHandler = Handler(
    handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      return const NotFountPage();
    },
  );

  static void configureRoutes(FluroRouter router) {
    router.define(home, handler: _homeHandler);
    router.define(roomDetail, handler: _roomDetailHandler);
    router.define(login, handler: _loginHandler);
    router.define(register, handler: _registerHandler);
    router.notFoundHandler = _notFoundHandler;
  }
}
